package com.tanhua.manage.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tanhua.manage.enums.SexEnum;
import com.tanhua.manage.mapper.UserMapper;
import com.tanhua.manage.pojo.User;
import com.tanhua.manage.vo.Pager;
import com.tanhua.manage.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.stream.Collectors;

@Service
@Slf4j
public class UserService extends ServiceImpl<UserMapper, User> {

    @Autowired
    private UserMapper userMapper;



    /**
     * 根据条件获取用户分页数据
     *
     * @param page     当前页码
     * @param pageSize 页尺寸
     * @param id       用户id
     * @param nickname 昵称
     * @param city     居住城市
     * @return 用户分页数据
     */
//    public Pager<UserVo> queryByPage(Integer page, Integer pageSize, Long id, String nickname, String city) {
//        IPage<UserVo> pageData = this.userMapper.queryByPage(new Page<>(page, pageSize), id == null ? null : String.valueOf(id), nickname, city);
//
//        //处理性别名称的问题
//        pageData.getRecords().forEach(userVo -> {
//            userVo.setSex(SexEnum.getSexByValue(Integer.valueOf(userVo.getSex())));
//            //查询用户状态
//            userVo.setUserStatus(this.userFreezeService.getFreezeStatusByUserId(userVo.getId()) ? "2" : "1");
//        });
//
//        return new Pager<>(pageData);
//    }
}
